using System.Collections.Generic;
using UnityEngine;

namespace HEFramework
{
    /// <summary>
    ///
    /// 组件行为
    /// 
    /// ----------------------------------------
    /// 作者 pan
    /// 创建时间：2022-09-22 10:08:51
    /// ----------------------------------------
    /// </summary>
    public class TransformBehaviour : MonoBehaviour
    {
        [Header("组件列表")] [SerializeField] private List<Transform> transforms;
        private Dictionary<string, Transform> maps = new();

        public List<Transform> Transforms => transforms;

        public Transform GetTransform(string _name)
        {
            Transform transform;
            if (maps.TryGetValue(_name, out transform))
            {
                return transform;
            }

            for (int i = 0; i < transforms.Count; i++)
            {
                if (transforms[i].name == _name)
                {
                    transform = transforms[i];
                    maps.Add(_name, transform);
                    return transform;
                }
            }

            return null;
        }
    }
}